

* Royston-Parmar models


use book-basedata-replication, clear

*estimate Royston-Parmar model for the same model specification
eststo, title(Royston-Parmar): xi: stpm2 med2 prevcris2 viol2 crisdur2 jointdem victory2 contig2 i.order5 /* 
*/		if _t<3650, scale(hazard) df(5) tvc(med2 i.order5) dftvc(med2:1 5)


*compare to Royston-Parmar model in which all covariates have time-varying effects
xi: stpm2 med2 prevcris2 viol2 crisdur2 jointdem victory2 contig2 i.order5 /* 
*/		if _t<3650, scale(hazard) df(3) tvc(med2 prevcris2 viol2 crisdur2 /* 
*/		jointdem victory2 contig2 i.order5) dftvc(med2:1 prevcris2:1 viol2:1 /* 
*/		crisdur2:1 jointdem:1 victory2:1 contig2:1 3)



* Generate Tables

esttab, star(† 0.1 * 0.05 ** 0.01) se  mtitle nodepvar  /*
*/ 		drop(xb0: _rcs__Iorder* _Iorder* _rcs? _d_* _s0_*) /*
*/ 		order(med2 med2_t _rcs_med21) /*
*/ 		varlabels(med2 "Mediation"/*
*/ 		med2_t "Mediation * time"/*
*/ 		_rcs_med21 "Mediation spline"/*
*/ 		prevcris2 "Previous crises"/*
*/ 		viol2 "Violence level"/*
*/ 		crisdur2 "Crisis duration"/*
*/ 		jointdem "Democratic dyad"/*
*/ 		victory2 "Victory"/*
*/ 		contig2 "Contiguity"/*
*/ 		prevcris2_t "Previous crises * time"/*
*/ 		viol2_t "Violence level * time"/*
*/ 		crisdur2_t "Crisis duration * time"/*
*/ 		jointdem_t "Democratic dyad * time"/*
*/ 		victory2_t "Victory * time"/*
*/ 		contig2_t "Contiguity * time"/*
*/		_cons Constant)
esttab using _table1_wRP.tex, star(\dagger 0.1 * 0.05 ** 0.01) se label  /*
*/ 		replace drop(xb0: _rcs__Iorder* _Iorder* _rcs? _d_* _s0_*) /*
*/ 		order(med2 _rcs_med21) /*
*/ 		varlabels(med2 "Mediation"/*
*/ 		med2_t "Mediation $\times$ time"/*
*/ 		_rcs_med21 "Mediation spline"/*
*/ 		prevcris2 "Previous crises"/*
*/ 		viol2 "Violence level"/*
*/ 		crisdur2 "Crisis duration"/*
*/ 		jointdem "Democratic dyad"/*
*/ 		victory2 "Victory"/*
*/ 		contig2 "Contiguity"/*
*/ 		prevcris2_t "Previous crises $\times$ time"/*
*/ 		viol2_t "Violence level $\times$ time"/*
*/ 		crisdur2_t "Crisis duration $\times$ time"/*
*/ 		jointdem_t "Democratic dyad $\times$ time"/*
*/ 		victory2_t "Victory $\times$ time"/*
*/ 		contig2_t "Contiguity $\times$ time"/*
*/		_cons Constant)  /*
*/ 		b(%9.3g) nodepvar mtitle nonotes booktabs /*
*/ 		addnotes("cluster robust standard errors in parentheses, $\dagger$ p \textless 0.1, * p \textless 0.05, ** p \textless 0.01" /*
*/ 		"restricted cubic splines modeling the baseline hazard not reported") 

